FileSetEOF command

Syntax
FileSetEOF refNum

Description
Sets the end-of-file (length) of a file opened with FileOpen. 

The SetEOF function sets the end-of-file (length in bytes) of the specified file. 

If you set the new end-of-file to a number less than the current end-of-file, the file is truncated. Setting the end-of-file to 0 (zero) deletes all data in the file.

If you set the new end-of-file beyond the current end-of-file, the file size increases on the volume to accomodate the new size. The newly-allocated space at the end of the file contains garbage data (whatever data happened to be on the volume where the new space was allocated).

Note:  If not used carefully, FileSetEOF can potentially delete data in the specified file. Don't use FileSetEOF unless you are confident with reading and writing directly to files. For more information on file manipulation using the FileIO Extension, see “Reading and writing data files” on page 136.

Examples
Variable theFile, theData, refNum
theFile = (FindFolder "desk") & "FileIO Demo"
File(theFile).Text = "This is some text in the FileIO Demo file."
refNum = FileOpen theFile
FileSetEOF refNum, 17      // Set the length of the file to 17, truncating the rest of the file
theData = FileRead refNum, "all"
FileClose refNum
Message theData

See Also
Using the FileIO extension (page 136)

Author Info
FileSetEOF, part of FileIO Extension
Copyright © 1998 Life OnLine Software (lr). All rights reserved.